<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>111</li>
        <li>222</li>
        <li>333</li>
    </ul>
    <ol id="ol">
        <li>111</li>
        <li>222</li>
        <li>333</li>
    </ol>
    <script>
        /* 
            需求：获取li标签
        */
        // 
        const lists = document.getElementsByTagName("li");
        console.log(lists); //HTMLCollection(6) ：返回的是一个HTML标签的集合，里面有6个元素
        console.log(lists[0]);
        console.log(lists[0].innerText);
        //需求：遍历这个HTMLCollection把所有的li都打印出来
        for (let i = 0; i < lists.length; i++) {
            console.log(lists[i]);
        }

        const ols = document.getElementById("ol");
        console.log(ols);
        // 获取ols这个对象的li标签
        const olis = ols.getElementsByTagName("li");
        console.log(olis);





    </script>
</body>

</html>